/**
 * 系统日志表格列
 */
import { ref, h } from 'vue'
import { Log } from '../../../entity/system/log'
import { TableColumnProps } from '@/components/base/table/table-props'

// @ts-ignore
export const columns: Array<TableColumnProps<Log>> = [
  {
    title: '编号',
    // @ts-ignore
    customRender: ({ index }) => index + 1,
    width: 60,
    align: 'center',
  },
  {
    title: '用户名',
    dataIndex: 'userName',
    width: 100,
  },
  {
    title: '用户操作',
    width: 150,
    dataIndex: 'operation',
  },
  {
    title: '执行结果',
    dataIndex: 'result',
    customRender: ({ record }) => (record.result == 1 ? '成功' : '失败'),
    width: 200,
  },
  {
    title: '请求结果',
    dataIndex: 'resultInfo',
    ellipsis: true,
    width: 200,
  },
  {
    title: 'ip',
    dataIndex: 'ip',
    width: 120,
  },
  {
    title: '请求方法',
    dataIndex: 'method',
    ellipsis: true,
    width: 200,
  },
  {
    title: '异常信息',
    dataIndex: 'errorInfo',
    ellipsis: true,
    width: 200,
  },
  {
    title: '请求参数',
    width: 400,
    dataIndex: 'params',
  },
  {
    title: '执行时长(毫秒)',
    width: 140,
    dataIndex: 'time',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    customRender: ({ record }) => (record.createTime ? record.createTime.replace('T', ' ') : ''),
    width: 200,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 200,
    align: 'center',
    fixed: 'right',
  },
]
